package per.dj.testpro.entity.protocol;

import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class Qy_08 implements IMessageBody{

    //用户id
    private Integer userId;

    //充电口号
    private Integer portNo;

    //启充时间年月日时分秒（BCD[6]）
    private String startChargingTime;

    //充电电压
    private Integer batteryVoltage;

    //充电电流
    private Integer batteryElectric;

    //流水号
    private byte serialNumber;

    public final byte[] WriteToBytes() {
        return null;
    }

    public final void ReadFromBytes(byte[] messageBodyBytes) {

        setUserId(Integer.valueOf(
                String.format("%02X", messageBodyBytes[0]) +
                String.format("%02X", messageBodyBytes[1]) +
                String.format("%02X", messageBodyBytes[2]) +
                String.format("%02X", messageBodyBytes[3]),16));
        setPortNo(Integer.valueOf(String.format("%02X", messageBodyBytes[4]),16));

        setStartChargingTime(String.format("%02X", messageBodyBytes[5])+
                String.format("%02X", messageBodyBytes[6])+
                String.format("%02X", messageBodyBytes[7])+
                String.format("%02X", messageBodyBytes[8])+
                String.format("%02X", messageBodyBytes[9])+
                String.format("%02X", messageBodyBytes[10]));

        setBatteryVoltage(Integer.valueOf(String.format("%02X", messageBodyBytes[11]),16));
        setBatteryElectric(Integer.valueOf(String.format("%02X", messageBodyBytes[12]),16));
        setSerialNumber(messageBodyBytes[13]);
    }
}
